lengthChance("taskfind-with-name",20)
function selectColor(){ 
    $(".find-plan select").change(function (){
        if($(".find-plan option:selected")!=$(".find-plan select").first()){
            $(".find-plan select").css("color","black")
        }

      })
      $("button:reset").click(function(){
        $(".find-plan select").css("color","#C0C4CC")
      })
 }
 selectColor()
 function  toDataAll() {
      $(".data-center").on("click",function () {
        $(".mainLeft ul li a").eq(0)[0].click();
        })
   }
   toDataAll()

   //接口
allPlanDataCall(proShow)
$("#pro-pageSize").on("change",function(){
  allPlanDataCall(proShow)
})
function proShow(data){ 
  // debugger
    console.log(data)
    var proFlag =1
    let activeNum =1
    let leftNum =4;
    let rightNum=4
    $(".total").text("共"+data.total+"条")
    // data.pages;
    if(data.pages>7){
            showLi(proFlag);
    }else{
        for (let index = 0; index <10 ; index++) {
            $("#liWrapper").append("<li>"+(index+1)+"</li>")
        }
    }

        $("#liWrapper").on("click","li",function(){
            // console.log((proFlag))
            // console.log($(this).text())
             activeNum = $(this).text()
            if($(this).text()<=leftNum){
                proFlag = 1
            }else if($(this).text()>(data.pages-rightNum)){
                proFlag = 0
            }
            else if($(this).text()==="···"){
                proFlag = -1
            }
            else{
                proFlag = $(this).text()
            }
            // console.log( proFlag)
        })
        $("#liWrapper").on("click","li",function(){
            if(data.pages>7){
                showLi(proFlag);
        }else{
            for (let index = 0; index <data.pages ; index++) {
                $("#liWrapper").append("<li>"+(index+1)+"</li>")
            }
        }
        })
        function showLi(num){
            $("#liWrapper").html("")
            if(num == 1){
                for (let index = 0; index < 6; index++) {
                    $("#liWrapper").append("<li>"+(index+1)+"</li>") 
                }
                $("#liWrapper").append("<li class='pro-toNext'>···</li>") 
                $("#liWrapper").append("<li>"+data.pages+"</li>")
                
            }else if(num==0){
                $("#liWrapper").append("<li>1</li>") 
                $("#liWrapper").append("<li class='pro-toPrev'>···</li>") 
                for (let index = data.pages-6; index < data.pages; index++) {
                    $("#liWrapper").append("<li>"+(index+1)+"</li>") 
                }
             }else if(num==-1){

             }else{
                $("#liWrapper").append("<li>1</li>") 
                $("#liWrapper").append("<li class='pro-toPrev'>···</li>")
                for (let index=(num-2); index<(+num+3); index++) {
                    $("#liWrapper").append("<li>"+(index)+"</li>") 
            }
                $("#liWrapper").append("<li class='pro-toNext'>···</li>")
                $("#liWrapper").append("<li>"+data.pages+"</li>")
        }
        iftopOrBottom()
        proLiColor()
        function proLiColor() {  
            $("#liWrapper li").each(function(index,el){
                if($(el).text()==activeNum){
                    $(el).addClass("active")
                }
    
            })
        }

        function ellipsisFun(){
            $("#liWrapper .pro-toNext").on("mouseenter",function (){
                $(this).text(">>").css("color","#7AC8F9")
              })
            $("#liWrapper .pro-toNext").on("mouseleave",function (){
                $(this).text("···").css("color","black")
              })
            $("#liWrapper .pro-toNext").on("click",function (){
                proFlag= +proFlag+5;
                if(proFlag>(data.pages-rightNum-5)){
                    activeNum = data.pages;
                    showLi(0);
                }else{
                    activeNum = proFlag;
                    showLi(proFlag);
                }
                
              })

            $("#liWrapper .pro-toPrev").on("mouseenter",function (){
                $(this).text("<<").css("color","#7AC8F9")
              })
            $("#liWrapper .pro-toPrev").on("mouseleave",function (){
                $(this).text("···").css("color","black")
              })
              $("#liWrapper .pro-toPrev").on("click",function (){
                proFlag=activeNum-5;
                if(proFlag<=leftNum){
                    activeNum =1;
                    showLi(1);   
                }else{
                    activeNum = proFlag;
                    showLi(proFlag);
                }

              })

        }
        ellipsisFun()
        function iftopOrBottom() {
            if(activeNum<=1){
                activeNum=1
                $(".pro-btn-prev").css({
                        "cursor":"not-allowed",
                        "color":"#D6CECF"
                    });
                   
            }else{
                $(".pro-btn-prev").css({
                    "cursor":"pointer",
                    "color":"#000000"
                });
            }
            if(activeNum>=data.pages){
                activeNum = data.pages;
                $(".pro-btn-next").css({
                    "cursor":"not-allowed",
                    "color":"#D6CECF"
                })
            }else{
                $(".pro-btn-next").css({
                    "cursor":"pointer",
                    "color":"#000000"
                });
            }
        }
        
        $("#proGoto").val(activeNum)
        allPlanDataCall(tabShow)
}
proGoto()
function proGoto(){
    $("#proGoto").on("focus",function(){
        $(this).css({"borderColor":"#409EFF","outline":"#409EFF"})
    })
    $("#proGoto").on("blur",function(){
        $(this).css({"borderColor":"#DCDFE6"})
        let val = +$(this).val()
        if(val%1==0){
            activeNum = val;
            if(val<=4){
                showLi(1)
            }
            else if(val>=data.pages-rightNum){
                showLi(0)
            }
            else{
                showLi(val)
            }
        }else{
            $(this).css("borderColor","red")
        }
        
    })
}

    function upAndDown(){
        $(".pro-btn-prev").on("click",function(){
            activeNum--
            if(activeNum<=4){
                showLi(1)
            }
            else if(activeNum>=data.pages-rightNum){
                showLi(0)
            }
            else{
                showLi(activeNum)
            }
            allPlanDataCall(tabShow)
            
        })
        $(".pro-btn-next").on("click",function(){
            activeNum++
            if(activeNum<=4){
                showLi(1)
            }
            else if(activeNum>=data.pages-rightNum){
                showLi(0)
            }
            else{
                showLi(activeNum)
            }
            allPlanDataCall(tabShow)
            
        })
    }
    upAndDown()
    // console.log( $("#liWrapper li.active")[0]);
    // $("#liWrapper li.active")[0].click();
 }
function profun(){ 
    $(".pro-btn-prev").on("click",function(){
      allPlanDataCall(tabShow)
    })
    $(".pro-btn-next").on("click",function(){
      allPlanDataCall(tabShow)
    })
    $("#liWrapper").on("click","li",function(){
      allPlanDataCall(tabShow)
    })
 }
profun()
function tabShow(data){

  if(data){
     let arr = data.list;
         $("#pro-tbody").html("")
 $(arr).each(function(index,el){
     
 })
  }
}
tabShow()